using System;
using FluentNHibernate.Mapping;
using FluentNHibernate.Conventions;

namespace Caramel.NHibernate.Entities.Conventions
{
	public class HasManyConvention : IHasManyConvention
	{
		#region IConvention<IOneToManyPart> Members

		public bool Accept(IOneToManyPart target)
		{
			return true;
		}

		public void Apply(IOneToManyPart target)
		{
			target.
				Cascade.
				AllDeleteOrphan().
				Inverse().
				LazyLoad();
		}

		#endregion
	}
}
